class Solution {
public:
    void merge(vector<int>& nums1, int m, vector<int>& nums2, int n) {
        // 解法1：通过辅助数组，定义三个指针，cur1，cur2，cur，
        // cur 指向辅助数组

        vector<int> temp(m + n);
        int cur = 0, cur1 = 0, cur2 = 0;
        
        while(cur1 < m && cur2 < n)
        {
            if(nums1[cur1] > nums2[cur2]) temp[cur++] = nums2[cur2++];
            else temp[cur++] = nums1[cur1++];
        }
        while(cur1 < m) temp[cur++] = nums1[cur1++];
        while(cur2 < n) temp[cur++] = nums2[cur2++];

        for(int i = 0; i < m + n; i++)
        {
            nums1[i] = temp[i];
        }
    }
};
